﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>toFindPwd</title>
    <link rel="stylesheet" type="text/css" href="https://kao.acmcoder.com/css/jquery.cxdialog.css" />
    <link rel="stylesheet" type="text/css" href="https://kao.acmcoder.com/css/all-exam.css" />
    <link rel="stylesheet" type="text/css" href="https://kao.acmcoder.com/css/user/login.css" />
</head>
<body>
    <!--head-->
    <div class="head">
        <div class="head-bar public">
            <div class="logo">
                <p><span>家用版</span></p>
            </div>
        </div>
    </div>
    <!--head  end-->
    <div class="acm-container" style="padding-bottom: 200px;">
        <div class="userCnt">
            <div class="loginCnt">
                <h1>找回密码</h1>
                <div class="login-box">
                    <ul>
                        <li>
                            <span class="regisit-span">+86</span>
                            <input type="text" class="login-text input regisit-phone" id="phone_ipt" placeholder="请输入注册时使用的手机号" maxlength="11" />
                        </li>
                        <li>
                            <input type="text" class="login-text input regisit-send-input" id="vcode_ipt" placeholder="验证码" />
                            <a href="javascript:void(0)" id="get_mob_yzm_btn" class="regisit-send">获取验证短信</a>
                        </li>
                        <li>
                            <input type="password" class="login-text input" id="pwd_ipt" placeholder="请输入新密码" maxlength="20" />
                        </li>
                        <li>
                            <input type="button" id="reset_pwd" class="login-btn btn" value="重置密码">
                        </li>
                    </ul>
                </div>
                <div class="login-f">
                    我已想起密码，<a href="/Login/Login">马上登录 >></a>
                </div>
            </div>
        </div>
    </div>
    <!--验证码弹窗 end-->
    <!--footer-->
    <script src="https://kao.acmcoder.com/js/jquery.min.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script type="https://cdn.acmcoder.com/static/1.0.1/js/jquery.cookie.js" src="jquery.cookie.js" tppabs="">
    </script>
    <script src="https://kao.acmcoder.com/js/footer-exam.js" tppabs=""></script>
    <script src="https://kao.acmcoder.com/js/jquery.cxdialog.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="https://kao.acmcoder.com/js/all.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="https://kao.acmcoder.com/js/user/regisit.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="https://kao.acmcoder.com/js/common.min.js" tppabs="" type="text/javascript" charset="utf-8"></script>
</body>
</html>
<script>
    var InterValObj;
    var curCount;
    // timer处理函数
    var SetRemainTime = function () {
        if (curCount == 0) {
            window.clearInterval(InterValObj);//停止计时器
            $('#get_mob_yzm_btn').removeAttr('disabled');//启用按钮
            $('#get_mob_yzm_btn').text('重新发验证码');
        } else {
            curCount--;
            $('#get_mob_yzm_btn').text(curCount + 's后重新获取');
        }
    };
    // 获取验证码
    $(document).on('click', '#get_mob_yzm_btn', function () {
        var mobile = $('#phone_ipt').val();
        if (InterValObj && curCount > 0) {
            return;
        }
        curCount = 59;
        //设置button效果，开始计时
        $(this).attr('disabled', 'true');
        $(this).text(curCount + 's后重新获取');

        InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一
        $.ajax({
            url: "/Login/Ynzheng",
            type: 'post',
            dataType: 'json',
            data: { phone: mobile },
            success: function (data) {
                if (data == 1) {

                }
                else {
                    alert("发送验证码失败，请联系管理员");
                }
                return;
            }
        });
    });
    $("#reset_pwd").click(function () {
        $.ajax({
            url: "/Login/toFindPwd",
            type: "post",
            data: { phone: $('#phone_ipt').val(), vcode_ipt: $("#vcode_ipt").val(), pwd_ipt: $("#pwd_ipt").val() },
            success: function (data) {
                if (data == -1) {
                    alert("请填写完整信息");
                    $('#phone_ipt').val("");
                    $("#vcode_ipt").val("");
                    $("#pwd_ipt").val("");
                    $('#phone_ipt').focus();
                }
                else if(data==-2)
                {
                    alert("验证码输入不正确");
                    $("#vcode_ipt").val("");
                    $("#vcode_ipt").focus();
                }
                else if(data==-3)
                {
                    alert("用户不存在");
                    $('#phone_ipt').val("");
                    $('#phone_ipt').focus();
                }
                else if(data==0)
                {
                    alert("保存用户失败");
                    $('#phone_ipt').val("");
                    $("#vcode_ipt").val("");
                    $("#pwd_ipt").val("");
                    $('#phone_ipt').focus();
                }
                else if(data>0)
                {
                    location.href = "/Login/Login";
                }
            }
        })
    })

</script>
